package cn.zqy.demo2.day02.demo03;

import java.util.ArrayList;
import java.util.Collections;

/**
 * 斗地主综合案例:
 *         1.准备牌
 *         2.洗牌
 *         3.发牌
 *         4.看牌
 */
public class FightLandlord {
    public static void main(String[] args) {
        // 1.准备牌
        ArrayList<String> poker = new ArrayList<>();
        poker.add("大王");
        poker.add("小王");
        String[] colors = new String[] {"♥","♣", "♠", "♦"};
        String[] numbers = new String[] {"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        for (String number :numbers) {
            for (String color:colors) {
                poker.add(color + number);
            }
        }
        System.out.println(poker);
        //2.洗牌
        Collections.shuffle(poker);
        System.out.println(poker);

        //3.发牌
        ArrayList<String> player01 = new ArrayList<>();
        ArrayList<String> player02 = new ArrayList<>();
        ArrayList<String> player03 = new ArrayList<>();
        ArrayList<String> dipai = new ArrayList<>();

        for (int i = 0; i < poker.size(); i++) {
            String p = poker.get(i);
            // 索引
            if(i>50) {
                dipai.add(p);
            } else if (i % 3 == 0) {
                player01.add(p);
            }else if (i % 3 == 1) {
                player02.add(p);
            }else if (i % 3 == 2) {
                player03.add(p);
            }
        }

        System.out.println("==========");
        //  4.看牌
        System.out.println("player01" + player01);
        System.out.println("player02" + player02);
        System.out.println("player03" + player03);
        System.out.println("底牌" + dipai);
    }
}
